-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rishav/52 : adding cleanup and commands left in /health #54
base: master
Are you sure you want to change the base?
Conversation
func (s *HTTPServer) getCommandsLeft() (int64, error) { | ||
configValue := config.LoadConfig() | ||
currentWindow := time.Now().Unix() / int64(configValue.Server.RequestWindowSec) | ||
key := fmt.Sprintf("request_count:%d", currentWindow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can reuse this part of the function @rishavvajpayee
@rishavvajpayee Currently, x-next-cleanup-time returns the number of seconds remaining until the next cleanup. However, in this PR, it seems you're setting it to represent the exact timestamp of the next cleanup in the health check endpoint. |
} | ||
|
||
w.Header().Set("x-next-cleanup-time", strconv.FormatInt(nextCleanup, 10)) | ||
w.Header().Set("x-commands-left", strconv.FormatInt(commandsLeft, 10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rishavvajpayee To enable Chrome or other browsers to access certain response headers, you need to include them in the Access-Control-Expose-Headers
header. This ensures the specified headers are accessible to client-side scripts.
( not added tests )